package com.example.kotlin;

import android.app.Application;
import android.content.Context;

import com.aserbao.aserbaosandroid.functions.database.greenDao.db.DaoSession;

/**
 * @ClassName: MyApplication
 * @Description: java类作用描述
 * @Author: chenmengjia
 * @Date: 2022/3/10 14:52
 */
public class MyApplication extends Application {

    protected static Context sContext;
    @Override
    public void onCreate() {
        super.onCreate();
       initGreenDao();
    }
    @Override
    protected void attachBaseContext(Context base) {
        sContext = this;
        super.attachBaseContext(base);
    }
    private void initGreenDao() {
//        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "aserbao.db");
//        SQLiteDatabase db = helper.getWritableDatabase();
//        DaoMaster daoMaster = new DaoMaster(db);
//        daoSession = daoMaster.newSession();
        MyDBUtil.getInstance().init();
    }

    private DaoSession daoSession;
    public DaoSession getDaoSession() {
        return daoSession;
    }

    public static Context getContext() {
        if (sContext == null) {
           // throw new GlobalException(GlobalException.APPLICATION_CONTEXT_IS_NULL);
        }
        return sContext;
    }

}
